package cn.edu.hunau.java.week02.day02.morning;

import java.awt.*;

public class Rectangle {
     Point location;
     int width;
     int height;

     public Rectangle(){

     }

    public Rectangle(int width,int height,Point location){
        this.width=width;
        this.height=height;
        this.location=location;
    }

     public Rectangle(int width,int height,int x,int y){

         this(width,height,new Point(x,y));
     }

     public double area(){
         return (this.width*this.height);
     }

     public boolean container(Point p) {
        return p.x >= this.location.x && p.x <= this.location.x + this.width && p.y >= this.location.y && p.y <= this.location.y + this.height;
     }
     public boolean container(int x,int y){
        return this.container(new Point(x,y));
     }
}
